package com.mkyong.app;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ReadWrite;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.tdb.TDBFactory;

public class TripleStore extends CustomStore {

	public void setupStore(String input, String output)
			throws FileNotFoundException {
		Dataset dataset = TDBFactory.createDataset(output);
		dataset.begin(ReadWrite.WRITE);
		Model tdb = dataset.getDefaultModel();

		tdb.read(new FileInputStream(input), null, "TTL");

		tdb.close();
		dataset.commit();
		dataset.end();
	}

	public Model getDefaultModel() {

		Dataset dataset = TDBFactory
				.createDataset(EndpointContextListner.DB_LOCATION);
		dataset.begin(ReadWrite.READ);
		return dataset.getDefaultModel();
	}

	@Override
	public void setupStore() throws Exception {

	}
}
